﻿using Inovout.Cloud.Applications.Models;
using Inovout.Cloud.Applications.Security.Models;
using Inovout.Descriptors;
using System.Collections.Generic;

namespace Inovout.Cloud.Console.Web.Models
{
    public class ApplicationCredentialInfo<T> : Dictionary<string, object> where T : IApplicationCredential
    {
        public ApplicationCredentialInfo(T applicationCredentialInfo)
            : base(ConvertTo(applicationCredentialInfo))
        {
            base.Add("_Type", typeof(T).Name);
        }
        private static IDictionary<string, object> ConvertTo(T applicationCredentialInfo)
        {
            return TypeDescriptor.Get(typeof(T)).GetPropertyValues(applicationCredentialInfo);
        }
    }
}